module Tipos
(
	Tk(Program_tk, End_tk, Function_tk, Subroutine_tk, If_tk, Then_tk, Elseif_tk, Else_tk, While_tk, Select_tk, Case_tk, Default_tk, Type_tk, Write_tk, Read_tk, Define_tk, Return_tk, Id_tk, Integer_tk, Real_tk, Character_tk, Logical_tk, Bool_tk, Int_tk, Float_tk, Char_tk, String_tk, Plus_tk, Minus_tk, Mult_tk, Div_tk, Exp_tk, LT_tk, LE_tk, GT_tk, GE_tk, NEQ_tk, EQ_tk, And_tk, Or_tk, Not_tk, LP_tk, RP_tk, LC_tk, RC_tk, PV_tk, VG_tk, PT_tk, DP_tk, Concat_tk, Atrib_tk, Error_tk),
	Token,
	Value(Int_v, Char_v, Bool_v, Real_v),
	Type(Int_t, Char_t, Bool_t, Real_t),
	Expr(Constant, Variable, Atrib, Sum, Sub, Mul, Div, Expo, Mod, Create, Set, Read)
) where


data Tk = 
        -- palavras reservadas
      Program_tk        -- program
    | End_tk            -- end

    | Function_tk       -- function
    | Subroutine_tk     -- subroutine

    | If_tk             -- if
    | Then_tk           -- then
    | Elseif_tk         -- elseif
    | Else_tk           -- else

    | While_tk          -- while
    | Select_tk         -- select
    | Case_tk           -- case
    | Default_tk        -- default

    | Type_tk           -- type
    | Write_tk          -- write
    | Read_tk           -- read
    | Define_tk         -- define
    | Return_tk         -- return

    | Id_tk String      -- identifier

        -- tipos
    | Integer_tk        -- integer
    | Real_tk           -- real
    | Character_tk      -- character
    | Logical_tk        -- logical

        -- literais
    | Bool_tk    Bool   -- booleanos
    | Int_tk     Int    -- inteiros
    | Float_tk   Float  -- floats
    | Char_tk    Char   -- chars
    | String_tk  String -- chars

        -- operadores aritmeticos
    | Plus_tk           -- +
    | Minus_tk          -- -
    | Mult_tk           -- *
    | Div_tk            -- /
    | Exp_tk            -- **

        -- operadores relacionais
    | LT_tk             -- <
    | LE_tk             -- <=
    | GT_tk             -- >
    | GE_tk             -- >=
    | NEQ_tk            -- /=
    | EQ_tk             -- ==

        -- operadores logicos
    | And_tk            -- and
    | Or_tk             -- or
    | Not_tk            -- not

        -- simbolos que abrem e fecham
    | LP_tk             -- (
    | RP_tk             -- )
    | LC_tk             -- [
    | RC_tk             -- ]

        -- outros simbolos
    | PV_tk             -- ;
    | VG_tk             -- ,
    | PT_tk             -- .
    | DP_tk             -- :
    | Concat_tk         -- +.
    | Atrib_tk          -- =

    | Error_tk deriving (Show)

type Token = (Tk, Int)

data Value = Int_v Int | Char_v Char | Bool_v Bool | Real_v Float deriving (Show)

data Type = Int_t | Char_t | Bool_t | Real_t deriving (Show)

data Expr = 
      Constant Value Type
    | Variable String
    | Atrib String Expr
    | Sum Expr Expr
    | Sub Expr Expr
    | Mul Expr Expr
    | Div Expr Expr
    | Expo Expr Expr
    | Mod Expr Expr
    | Create String Type
    | Set String Expr
    | Read deriving (Show)
